<?php require_once 'inc_security.php';
$db_config = new db_query('SELECT * FROM configuration WHERE con_type = "contact" LIMIT 1');
$configDetail = mysql_fetch_assoc($db_config->result);
$conBase->init_config($configDetail['con_type'],json_decode(base64_decode($configDetail['con_value']),1));
$myform = new generate_form();
$action = getValue('action','str','POST','');

if($action == 'execute'){
    $con_value = array();
    $con_value['address'] = getValue('address','str','POST','');
    $con_value['maps'] = getValue('maps','int','POST',0);
    $con_value['phone'] = getValue('phone','str','POST','');
    $con_value['mobile'] = getValue('mobile','str','POST','');
    $con_value['hotline'] = getValue('hotline','str','POST','');
    $con_value['fax'] = getValue('fax','str','POST','');
    $con_value['email'] = getValue('email','str','POST','');
    $con_value['yahoo'] = getValue('yahoo','str','POST','');
    $con_value['skype'] = getValue('skype','str','POST','');
    
    $con_value = base64_encode(json_encode($con_value));
    $myform->add('con_value','con_value',0,1,'');
    $myform->addTable($bg_table);
    $bg_errorMsg .= $myform->checkdata();
    if($bg_errorMsg == ''){
        $db_update = new db_execute($myform->generate_update_SQL('con_id',$configDetail['con_id']));
        unset($db_update);
        redirect('contactconfig.php?success=1');
    }
}

?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="vi" lang="vi" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?=$load_header?>
</head>
<body>
<div class="module_header bold fix"><?=$module_name?></div>
<div id="wrapper">
    <?=($bg_errorMsg ? '<div class="alert">'.$bg_errorMsg.'</div>' : '')?>
    <?=($bg_success ? '<div class="alert alert-success">'.'Cập nhật thành công'.'</div>' : '')?>
    <?php $form = new form();?>
    <?=$form->textnote('Thông tin liên hệ')?>
    <?=$form->form_open()?>
    <?=$conBase->Admin_form_config_contact()?>
    <?=$form->form_action(array('label'=>array('Cập nhật','Nhập lại'),'type'=>array('submit','reset')))?>
    <?=$form->form_close()?>
</div>
</body>
</html>